﻿using Abp.Authorization.Users;
using Abp.AutoMapper;
using Abp.Domain.Entities.Auditing;
using Mt.Organizations;
using Mt.Site.Core.WorkFlows.Enum;
using System;
using System.ComponentModel.DataAnnotations;

namespace Mt.Site.Core.WorkFlows.Process.Entities
{
    /// <summary>
    /// 1、归档数据，将WorkFlowPaper中一定时间以前的数据移入此表，则降低工作流列表页的查询压力
    /// 2、只提供查看功能，无法提供流程操作（主表变了，原流程操作代码不再生效）
    /// </summary>
    [AutoMapFrom(typeof(WorkFlowPaper))]
    public class WorkFlowPaperArchive : AuditedEntity<Guid>
    {
        /// <summary>
        /// 所属流程
        /// </summary>
        public Guid WorkFlowId { get; set; }

        /// <summary>
        /// 当前所处步骤
        /// </summary>
        public Guid NodeId { get; set; }

        public PaperState PaperState { get; set; }


        [StringLength(WorkFlowPaper.MaxTitleLength)]
        public string Title { get; set; }

        //部门名（来源）
        [StringLength(MtOrganizationUnit.MaxShortNameLength)]
        public string UnitName { get; set; }

        public long UnitId { get; set; }


        [StringLength(WorkFlowPaper.CoOperativeUnitIdsLength)]
        public string MainOperativeUserId { get; set; }

        [StringLength(WorkFlowPaper.CoOperativeUnitIdsLength)]
        public string CoOperativeUserIds { get; set; }


        [StringLength(WorkFlowPaper.CoOperativeUnitIdsLength)]
        public string CoOperativeUserIdsCopy { get;  set; }

        /// <summary>
        /// 协办部门id
        /// </summary>
        [StringLength(WorkFlowPaper.CoOperativeUnitIdsLength)]
        public string CoOperativeUnitIds { get; set; }

        [StringLength(AbpUserBase.MaxNameLength)]
        public string UserName { get; set; }

        /// <summary>
        /// 流水号
        /// </summary>
        public long SerialNumber { get; set; }

        /// <summary>
        /// 签发人
        /// </summary>
        [StringLength(WorkFlowPaper.MaxSignerLength)]
        public string Signer { get; set; }

        /// <summary>
        /// 文号
        /// </summary>
        [Required]
        [StringLength(WorkFlowPaper.MaxReferNumberLength)]
        public string ReferNumber { get; set; }

        public int PrintCount { get; set; }

        public ProgressState ProgressState { get; set; }
        public ApprovalResult ApprovalResult { get; set; }

        public DateTime? DeadLineTime { get; set; }

        public DateTime RegistrationTime { get;  set; }

        /// <summary>
        /// 归档日期
        /// </summary>
        public DateTime? ArchivedTime { get; set; }

        [StringLength(AbpUserBase.MaxNameLength)]
        public string ArchivedOperator { get; set; }

        public bool HasFinished { get;  set; }

        public int WhYear { get; set; }

        public int WhNumber { get; set; }

        [StringLength(WorkFlowPaper.MaxWhNameLength)]
        public string WhName { get; set; }

        public Guid? WenHaoId { get;  set; }

        //是否已读取到档案系统
        public bool Fetched { get; set; }

        public DateTime? FetchedTime { get; set; }
    }
}
